//package com.jxw.cloudpen.web.netty.websocketclient;
//
//import com.alibaba.fastjson.JSONObject;
//import com.jxw.cloudpen.web.netty.Entity.ChatGptRequest;
//import com.jxw.cloudpen.web.netty.Entity.ChatGptTxtRequest;
//import org.java_websocket.client.WebSocketClient;
//import org.java_websocket.drafts.Draft_6455;
//import org.java_websocket.handshake.ServerHandshake;
//
//import javax.net.ssl.SSLContext;
//import javax.net.ssl.TrustManager;
//import javax.net.ssl.X509TrustManager;
//import javax.sound.sampled.TargetDataLine;
//import java.net.URI;
//import java.net.URISyntaxException;
//import java.nio.ByteBuffer;
//import java.security.SecureRandom;
//import java.security.cert.X509Certificate;
//import java.util.HashMap;
//import java.util.Map;
//import java.util.concurrent.BlockingQueue;
//import java.util.concurrent.ExecutorService;
//import java.util.concurrent.Executors;
//import java.util.concurrent.LinkedBlockingQueue;
//
//
//public class MyWebSocketClientV5 {
//
//
//    public static void main(String[] args) throws Exception {
//        // 创建信任所有证书的SSLContext (生产环境不推荐)
//        SSLContext sslContext = SSLContext.getInstance("TLS");
//        sslContext.init(null, new TrustManager[]{new X509TrustManager() {
//            public void checkClientTrusted(X509Certificate[] chain, String authType) {}
//            public void checkServerTrusted(X509Certificate[] chain, String authType) {}
//            public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; }
//        }}, new SecureRandom());
//
//        // 添加必要的头部
//        Map<String, String> headers = new HashMap<>();
//        headers.put("Origin", "http://your-origin.com");
//
//        // 创建WebSocket客户端
//        WebSocketClient client = new WebSocketClient(
//                new URI("wss://your-websocket-url"),
//                new Draft_6455(),
//                headers,
//                5000, // 连接超时时间
//                sslContext.getSocketFactory()
//        ) {
//            @Override
//            public void onOpen(ServerHandshake handshakedata) {
//                System.out.println("连接已打开");
//            }
//
//            @Override
//            public void onMessage(String message) {
//                System.out.println("收到消息: " + message);
//            }
//
//            @Override
//            public void onClose(int code, String reason, boolean remote) {
//                System.out.println("连接关闭: " + reason);
//            }
//
//            @Override
//            public void onError(Exception ex) {
//                ex.printStackTrace();
//            }
//        };
//
//        // 连接
//        client.connect();
//    }
//
//
//}
